package com.jrx.anytxn.reporting.handler;

import com.jrx.anytxn.i18n.service.I18nService;
import com.jrx.anytxn.param.entity.I18nCore;
import com.jrx.anytxn.param.entity.I18nCoreFix;
import com.jrx.anytxn.param.mapper.ext.ExtI18nCoreFixMapper;
import com.jrx.anytxn.param.mapper.ext.ExtI18nCoreMapper;
import com.jrx.anytxn.sharding.util.SpringContextUtils;

/**
 * i18n转换类
 *
 * @author yf
 * date 2020/2/18 0018
 * @version V1.0
 **/
public class I18nTranslateHandler implements I18nService {

    @Override
    public String getI18nKeyValueByTenantId(String tenantId, String code, String value, String tableName, String language) {
        ExtI18nCoreMapper extI18nCoreMapper= SpringContextUtils.getBean("extI18nCoreMapper", ExtI18nCoreMapper.class);
        I18nCore i18nCore=extI18nCoreMapper.selectByCondition(tenantId,code,value,tableName,language);
        return i18nCore.getI18nValue();
    }

    @Override
    public String getI18nTextValueByTenantId(String tenantId, String code, String value, String language) {
        ExtI18nCoreFixMapper extI18nCoreFixMapper = SpringContextUtils.getBean("extI18nCoreFixMapper", ExtI18nCoreFixMapper.class);
        I18nCoreFix i18nCoreFix=extI18nCoreFixMapper.selectByTenIdAndCodeAndValueAndLang(tenantId,code,value,language);
        return i18nCoreFix.getI18nValue();
    }
}
